本篇來介紹用目前最熱門的 Docker
容器方式來快速包成一個電子郵件伺服器,如果功能要求不高需求只要基本可以正常運作又能不定時更新的服務,這一套是不錯用的郵件主機。
例: mailcow.xxx.net 也可以改成自己想要取的主機名稱。
yum update -y
yum install vim git wget openssh* sudo -y
curl -sSL https://get.docker.com/ | CHANNEL=stable sh
安裝完成後啟用 Docker 開機自動啟動及服務啟動 例如: CentoOS 7
systemctl enable docker.service ; systemctl start docker.service
curl -L https://github.com/docker/compose/releases/download/$(curl -Ls https://www.servercow.de/docker-compose/latest.php)/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
umask
0022
cd /opt
git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized
./generate_config.sh
Press enter to confirm the detected value '[value]' where applicable or enter a custom value.
Mail server hostname (FQDN) - this is not your mail domain, but your mail servers hostname:
Timezone [Asia/Taipei]: Asia/Taipei
vim /etc/postfix/master.cf
裡面將下面的
smtp inet n - - - - smtpd
修改成
#smtp inet n - - - - smtpd
然後存檔
:wq
Furthermore, to relay over a dockerized mailcow, you may want to add 172.22.1.1 as relayhost and remove the Docker interface from "inet_interfaces":
postconf -e 'relayhost = 172.22.1.1'
postconf -e "mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128"
postconf -e "inet_interfaces = loopback-only"
postconf -e "relay_transport = relay"
postconf -e "default_transport = smtp"
設定完之後重啟 Postfix
systemctl restart postfix
docker-compose pull
docker-compose up -d
https://ip
,預設帳號為:admin 密碼為:moohoo。這樣子就可以開始使用了